/*
 * Copyright (C) 2005-2006 Dmitri Maximovich <maxim@md.pp.ru>
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */
var AddServer = {

  onLoad: function() {
    var id = window.arguments[0];
    if (id != null) {
      var server = P.getServer(id);
      document.getElementById("name").value = server.name;
      document.getElementById("url").value = server.url;
      document.getElementById("type").selectedIndex = server.type;
    }
  },

  onSave: function() {
    var name = document.getElementById("name").value;
    var url = document.getElementById("url").value;
	var type = document.getElementById("type").selectedIndex;
	if (name == "" || url == "") {
	  alert("All fields should be entered");
	  return false;
	}
	var id = window.arguments[0];
	if (id == null) {
      P.addServer(name, url, type);
	}
	else {
	  P.updateServer(id, name, url, type);
	}
    return true;
  }

};
 